<template>
  <div class="commodity">
    <div class="hot-swiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="i in 3">
          <recommended-good></recommended-good>
        </div>
      </div>
      <div class="swiper-button-next"></div>
      <div class="swiper-button-prev"></div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.css";
import RecommendedGood from "./components/recommended-good";

export default {
  name: "hot-commodity",
  components: {RecommendedGood},
  data() {
    return {
      value: '',
      currentSwiper: ''
    }
  },
  created() {

  },
  mounted() {
    this.initSwiper();
  },
  methods: {
    // 初始化swiper
    initSwiper() {
      this.currentSwiper = new Swiper(".hot-swiper", {
        slidesPerView: 6,
        spaceBetween: 30,
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
          hideOnClick: true,
        },
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
        },
      });
    },
  },
}
</script>

<style scoped lang="less">
.commodity {
  position: relative;
  z-index: 2;
  width: 1200px;
  margin: 0 auto;
  margin-top: 30px;
  overflow: hidden;
  .hot-swiper {
    width: 100%;
  }
  .swiper-button-next {
    color: #AAAAAA;
    text-align: center;
    width: 30px;
    height: 30px;
    background-color: rgba(0,0,0,.3);
    &:after {
      font-size: 22px;
      color: #FFFFFF;
    }
  }
  .swiper-button-prev {
    color: #AAAAAA;
    text-align: center;
    width: 30px;
    height: 30px;
    background-color: rgba(0,0,0,.3);
    &:after {
      font-size: 22px;
      color: #FFFFFF;
    }
  }
  .swiper-slide {
    text-align: center;
    font-size: 18px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .swiper-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
</style>